function SOLUTION=Solver_Main(PP,StdVec,FileName)
PP          =   Setup_PP(PP);
%% Steady State
PSI_0       =   1;
DiscFactor_0=   0.02;
SS          =   SteadyState_Solver(PP,PSI_0,DiscFactor_0);

%% Construct the Model Structure
MODEL       =   Setup_MODEL(PP,SS);

% Check the Steady State in Equation Blocks
Res_NK      =   Equ_NK(PP,SS,0);
Res_HH      =   Equ_HH(PP,SS,MODEL,0);

if max(abs([Res_NK;Res_HH]))<1e-5
    fprintf('Steady State is Correct!\n');
else
    error('Steaty State is not Correct, check it  ...');
end


%% Compute the Jacobian
EquJac          =   struct();
EquJac.HH       =   Equ_HH(PP,SS,MODEL,1,[],[],1);
EquJac.HH_Aux   =   Equ_HH_Aux(PP,SS,MODEL,1,[],[],1);
EquJac.NK       =   Equ_NK(PP,SS,1);

fir_ord         =   JacAssemble(MODEL,EquJac);
%% IRF
tic;
[gx,hx,gxhx_ExitFlag,gxhx_Info]=gx_hx(fir_ord,1);
fprintf(['Perturbation is Solved, Elapse Time=',num2str(toc,'%.2f'),'s\n']);
if gxhx_ExitFlag~=1
    warning('Perturbation Solution is problematic');
    SOLUTION    =   [];
    return
else
    solution    =   struct('gx',gx,'hx',hx);
    
end
% StdVec          =   [1 1 1 -1 -1 60]'*0.01/4;
IRF             =   IRF_1order(MODEL,solution,StdVec,[],4*20);

SOLUTION        =   struct('PP',PP,'SS',SS,'MODEL',MODEL,'EquJac',EquJac,...
                           'fir_ord',fir_ord,'gxhx',solution,'IRF',IRF);
if nargin==3 && ~isempty(FileName)
    save([FileName,'.mat'],'PP','SS','MODEL','EquJac','fir_ord','solution','IRF');
end